<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box{
            width:300px;
            height:300px;
           
            margin:0  auto;
        }
    </style>
    </head>
    <body>
        <div  class="box">
            <img src=" https://www.runoob.com/images/pic_bulboff.gif      "     id="deng"  />
            <input  type="button"      value="开灯"    onclick="keidong(  )"   id="m"   />
    
    
    
        </div>
        <script>
        var  i=1;
        function      keidong(){
          
            
            if(i==1){
            deng.src="https://www.runoob.com/images/pic_bulbon.gif" ;
            m.value="关灯";
          
              i=0;
            
        }else{
         
           
            deng.src="https://www.runoob.com/images/pic_bulboff.gif   " ;
            m.value="开灯";
            
            i=1;
    
        }
        }
    
    
        
        
        
        
        </script>
        
    </body>
    </html>